<template>
    <a v-if="showLinkTag" :target="target" :href="linkUrl">
        <slot></slot>
    </a>
    <router-link v-else :to="{path:linkUrl}"><slot></slot></router-link>
</template>


<script>
    export default {
        name:"wioc-link-url",
        data(){
            return {
                baseUrl:""
            }
        },
        props:{
            href:String,
            target:{
                type:String,
                default:"_self"
            }
        },
		created(){
		},
        computed:{
            linkUrl:function(){
                if(this.href&&this.href.indexOf('http')!=-1){
					// 外链接
                    return `${this.href}`
                }else{
                    return `${this.baseUrl}${this.href}`
                }
            },
            showLinkTag:function(){
                if( this.href&&this.href.indexOf('http')!=-1 ){
                    return true
                }else{
                    return false
                }
            }
        }
    }

</script>

<style lang="less" scoped>
    /*包含以下四种的链接*/
    a{
        text-decoration:none;
        color:#333;
    }
    /*正常的未被访问过的链接*/
    a:link {
        text-decoration: none;
    }
    /*已经访问过的链接*/
    a:visited {
        text-decoration: none;
    }
    /*鼠标划过(停留)的链接*/
    a:hover {
        text-decoration: none;
    }
    /* 正在点击的链接*/
    a:active {
        text-decoration: none;
    }

</style>

